<template>
	<view class="goods-detail">

		<!-- 顶部 -->
		<view class="dt-nav">
			<view class="content">
				<text class="iconfont" @click="navBack">&#xe609;</text>
				<view class="right">
					<text class="iconfont" v-if="data.attention == 1" @click="onStoreIcon(1)" style="color: #ff557d; opacity: 1; font-size: 54upx;">&#xe62a;</text>
					<text class="iconfont" v-else @click="onStoreIcon(3)">&#xe645;</text>
					<text class="iconfont" v-if="data.collect == 1" @click="onShopIcon(2)" style="color: #ff557d; opacity: 1; font-size: 54upx;">&#xe65c;</text>
					<text class="iconfont" v-else @click="onShopIcon(4)" style="font-size: 54upx;">&#xe658;</text>
				</view>
			</view>
		</view>

		<!-- 轮播 start -->
		<swiper class="dt-swiper" :indicator-dots="true" indicator-color="rgba(0, 0, 0, .3)" indicator-active-color="#fff"
		 :autoplay="true" :interval="4000" :duration="400" circular="true">
			 <!-- <swiper-item v-for="(video,sub) in data.product_video" :key="sub">
				 <view class="swiper-item">
				 	<video 
					:src="video" 
					:autoplay="true" 
					:muted="true" 
					:show-mute-btn="true" 
					:enable-progress-gesture="false" 
					controls></video>
				 </view>
			 </swiper-item> -->
			<swiper-item v-for="(img,index) in data.product_imgs" :key="index">
				<view class="swiper-item">
					<image :src="img" mode="aspectFill"></image>
				</view>
				<!-- 9.9专区 -->

				<!-- 秒杀 -->
				<view class="sort" v-show="data.sysproid == 5">
					<image class="miaosha" src="/static/imgs/index/miaosha.png" mode="aspectFill"></image>
				</view>

				<!-- 拼团 -->
				<view class="sort" v-show="data.sysproid == 8">
					<image class="pingtuan" src="/static/imgs/index/pingtuan.png" mode="aspectFill"></image>
				</view>

				<!-- 土特产 -->
				<view class="sort" v-show="data.sysproid == 9">
					<image class="ttc" src="/static/imgs/index/ttc.png" mode="aspectFill"></image>
				</view>

				<!-- 二手 -->
				<view class="sort" v-show="data.sysproid == 10">
					<image class="ershou" src="/static/imgs/index/ershou.png" mode="aspectFill"></image>
					<view class="num">
						3888.1
					</view>
				</view>

				<!-- 其它 -->
			</swiper-item>
		</swiper>
		<!-- 轮播 end -->

		<!-- 价格与时间 -->
		<!-- 9,9 -->
		<view class="dt-time" v-if="data.product_sysproid == 1">
			<view class="dt-left">
				<text class="text1">￥<text class="text2">{{data.product_nowprice * 1}}</text></text>
				<text class="text3">￥{{data.product_preprice * 1}}</text>
			</view>
			<view class="dt-right">
				<!-- <view class="zk">{{data.product_discount * 1}}折</view> -->
				<image src="/static/imgs/white-jt.png" mode="aspectFill" class="dt-jt"></image>
				<view class="time-box">
					<text class="qg">{{data.product_catename}}</text>
				</view>
			</view>
		</view>

		<!-- 秒杀 -->
		<view class="dt-time" v-if="data.product_sysproid == 5">
			<view class="dt-left">
				<!-- .{{data.dec_nowprice}} -->
				<text class="text1">￥<text class="text2">{{data.product_nowprice * 1}}</text></text>
				<text class="text3">￥{{data.product_preprice * 1}}</text>
			</view>
			<view class="dt-right">
				<text class="iconfont dt-clock">&#xe61b;</text>
				<image src="/static/imgs/white-jt.png" mode="aspectFill" class="dt-jt"></image>
				<view class="time-box">
					<view class="box-t">
						距离本商品结束还剩
					</view>
					<view class="box-f">
						<tui-countdown class="tui-countdown-box1" :time="data.product_activity_surplus" width="40" color="#fff" bcolor="#666" height="40" bgcolor="#666" ></tui-countdown>
					</view>
				</view>
			</view>
		</view>

		<!-- 拼团 -->
		<view class="dt-time" v-if="data.product_sysproid == 8">
			<view class="dt-left">
				<text class="text1">￥<text class="text2">{{ data.product_nowprice * 1}}</text></text>
				<view class="ct">
					<text>2</text>
					人成团
				</view>
			</view>
			<view class="dt-right">
				<text class="iconfont dt-clock">&#xe61b;</text>
				<image src="/static/imgs/white-jt.png" mode="aspectFill" class="dt-jt"></image>
				<view class="time-box">
					<view class="box-t">
						距离本商品结束还剩
					</view>
					<view class="box-f">
						<tui-countdown :time="data.product_activity_surplus" class="tui-countdown-box1" width="40" color="#fff" bcolor="#666" height="40" bgcolor="#666"></tui-countdown>
					</view>
				</view>
			</view>
		</view>

		<!-- 土特产 -->
		<view class="dt-time dt-ttc" v-if="data.product_sysproid == 9">
			<view class="ttc-1">
				土特产专区
			</view>
			<view class="ttc-2">

				<image src="/static/imgs/white-jt.png" mode="aspectFill" class="dt-jt"></image>
				<view class="time-box">
					<text>￥{{data.product_nowprice * 1}}</text>
					<text>￥{{data.product_preprice * 1}}</text>
				</view>
			</view>
		</view>

		<!-- 二手 -->
		<view class="dt-time" v-if="data.product_sysproid == 10">
			<view class="dt-left">
				<text class="text1">￥<text class="text2">9</text>.9</text>
				<view class="ct">
					<text>2</text>
					人成团
				</view>
			</view>
			<view class="dt-right">
				<text class="iconfont dt-clock">&#xe61b;</text>
				<image src="/static/imgs/white-jt.png" mode="aspectFill" class="dt-jt"></image>
				<view class="time-box">
					<view class="box-t">
						距离本商品结束还剩
					</view>
					<view class="box-f">
						<tui-countdown class="tui-countdown-box1" width="40" color="#fff" bcolor="#666" height="40" bgcolor="#666" :time="1000"></tui-countdown>
					</view>
				</view>
			</view>
		</view>

		<!-- 价格与时间 end-->
		<view class="dt-title">
			<text class="t-l">{{data.product_name}}</text>
			<text class="t-r">仅剩:{{data.product_pronums}}</text>
		</view>
		<view class="dt-line2">
			配送方式：{{data.product_delivery}}
		</view>


		<!-- 邻居购买情况 -->
		<view class="dt-buy">
			<block v-for="(img,a) in data.order_user_shavatar" :key="a">
				<image :src="img.shavatar" mode="aspectFill"></image>
			</block>
			<view class="buy-r">
				已有<text>{{data.order_user_count}}</text>位邻居购买
			</view>
		</view>

		<!-- 评价 -->
		<view class="dt-assess">
			<view class="as-left">
				<image :src="data.shop_shavatar" mode="aspectFill"></image>
			</view>
			<view class="as-right">
				<view class="as-line1">
					{{data.shop_name}}
				</view>
				<view class="as-line2">
					<view class="item1">
						<text class="as-r">店铺信用评价</text>
						<tui-rate :current="data.shop_rank" :quantity="5" :size="14" active="#ffaa00"></tui-rate>
					</view>
					<text>共有{{ data.product_detail_procomment_count }}个消费评价 <text class="iconfont">&#xe600;</text></text>
				</view>

			</view>

		</view>

		<!-- 选择拼团 -->
		<view class="pt" v-if="data.product_sysproid == 8">
			<view class="pt-title">
				直接参与可快速成团
			</view>
			<view class="pt-item">
				<image src="/static/img/im/face/face_7.jpg" mode="aspectFill"></image>
				<text class="phone">139****8741</text>
				<view class="num">
					<view class="t">
						还差<text>1人</text>成团
					</view>
					<view class="b">
						<text>距结束</text>
						<tui-countdown class="tui-countdown-box1" width="26" splitor-color="#999" color="#999" bcolor="#fff" height="40"
						 bgcolor="#fff" :time="1000"></tui-countdown>
					</view>
				</view>
				<button>立即参团</button>
			</view>
		</view>

		<!-- 活动详情 -->
		<view class="dt-activity">
			<view class="at-item1">
				<image src="/static/imgs/activity.png" mode="aspectFill"></image>
				<text>活动</text>
			</view>

			<block v-for="(mj,index) in data.benefit" :key="index">
				<view class="at-item2" v-if="data.product_addgift == 1">
					满减：<text>购买每满{{mj.addgift_amout_srtart * 1}}元立减{{mj.addgift_discount * 1}}元
					</text>
				</view>
			</block>
			<view class="at-item2" v-if="data.product_everylimit != 0">
				限购：<text>每账号每天限购{{data.product_everylimit}}件</text>
			</view>
			<view class="at-item2" v-if="data.product_orderlimit != 0">
				限购：<text>每账号每单限购{{data.product_orderlimit}}件</text>
			</view>
		</view>

		<!-- 商品详情 -->
		<view class="detail">
			<view class="gs-detail">
				<image src="/static/imgs/detail-l.png" mode="aspectFill"></image>
				<text>商品详情</text>
				<image src="/static/imgs/detail-r.png" mode="aspectFill"></image>
			</view>
			<view class="gd-content">
				<view class="ct-item" v-for="(dt,index) in data.product_Rendering" :key="index">
					{{dt.name}}<text>{{dt.val}}</text>
				</view>
			</view>
		</view>

		<!-- 商品图片 -->
		<view class="goods-img" v-for="(img,sub) in data.product_product_detail_imgs" :key="sub">
			<image :src="img" mode="widthFix"></image>
		</view>

		<!-- 留言 leave word-->
		<view class="lWord">
			<view class="lw-h">
				<view class="titleName">
					<text class="h-1">留言</text>
					<!-- | countNum -->
					<text class="h-2">({{leaveData.count }})</text>
				</view>
				
				<view class="h-3"  @click="lyFlag = true">
					<text class="h-3-text">添加留言</text>
				</view>
				
				
			</view>
			<view class="content-box" v-show="appraise_status">

				<block v-for="(item,index) in leaveData.response" :key="index">

					<!-- 最新评价 -->
					<view class="bottom">

						<view class="bottom-top">
							<view class="top1">
								<view class="item1">
									<image :src="item.shavatar" :lazy-load="true" mode="aspectFill"></image>
									<text>{{item.nickname}}</text>
								</view>
								<view class="item2">
									<view class="a reply" @click="onReply(item)">
										<text class="iconfont">&#xe7f3;</text>
										<text>回复</text>
									</view>
									<view :class="['a','like',{'a-active': true}] " v-if="false">
										<text class="iconfont">&#xe65d;</text>
										<text>点赞</text>
									</view>
								</view>
							</view>
							<!-- 回复输入框 -->
						<!-- 	<view class="replied" v-if="item.replyFlag">
								<input type="text" v-model.trim="inputText" @blur="blur(item)"  :focus="item.replyFlag" :placeholder="`回复@${item.nickname}`" />
								<button type="primary" @click="onSend(item,0)">发送</button>
							</view> -->
							<view class="replied" v-if="item.replyFlag">
								<input type="text"  v-model.trim="inputText" @blur="blur(item)"  confirm-type="done" :focus="showFocus" :placeholder="`回复@${item.nickname}`" />
								<button type="primary" @click="onSend(item,0)">发送</button>
							</view>
						
							
							<view class="top2">
								<view class="text">
									<!-- 评论内容 -->
									{{item.coments}}
								</view>
							</view>

							<!-- 评论的回复 -->
							<view class="as-reply" v-for="(reply,subs) in item.message" :key="subs">
								<view class="who">
									<image :src="reply.shavatar" mode="aspectFill"></image>
									<text>{{reply.shname}}</text>
									<view v-if="false">
										店家
									</view>
								</view>
								<view class="content">
									{{reply.coments}}
								</view>
							</view>
							<!-- 评论的回复end -->

						</view>
					</view>
				</block>
			</view>

			<view class="seeMore" @click="getMore()">
				{{ lyMText }} <!-- <text class="iconfont">&#xe600;</text> -->
			</view>
		</view>

		<!-- 评价 -->
		<view class="lWord">
			<view class="lw-h">
				<text class="h-1">评价</text>
				<text class="h-2">({{appraise.count}})</text>
				<!-- <text class="h-3">添加评价</text> -->
			</view>
			<view class="content-box" v-show="true">
		
				<block v-for="(item,index) in appraise.response" :key="index">
		
					<!-- 最新评价 -->
					<view class="bottom">
		
						<view class="bottom-top">
							<view class="top1">
								<view class="item1">
									<image :src="item.shavatar" :lazy-load="true" mode="aspectFill"></image>
									<text>{{item.nickname}}</text>
								</view>
								<view class="item2">
									<view class="a reply" @click="onReply(item)">
										<text class="iconfont">&#xe7f3;</text>
										<text>回复</text>
									</view>
									<view :class="['a','like',{'a-active': true}] " v-if="false">
										<text class="iconfont">&#xe65d;</text>
										<text>点赞</text>
									</view>
								</view>
							</view>
							<!-- 回复输入框 -->
						<!-- 	<view class="replied" v-if="item.replyFlag">
								<input type="text" v-model.trim="inputText" @blur="blur(item)"  :focus="item.replyFlag" :placeholder="`回复@${item.nickname}`" />
								<button type="primary" @click="onSend(item,1)">发送</button>
							</view> -->
							<view class="replied" v-if="item.replyFlag">
								<input type="text"  v-model.trim="inputText" @blur="blur(item)"  confirm-type="done" :focus="showFocus" :placeholder="`回复@${item.nickname}`" />
								<button type="primary" @click="onSend(item,1)">发送</button>
							</view>
							<view class="top2">
								<view class="text">
									<!-- 评论内容 -->
									{{item.coments}}
								</view>
							</view>
		
							<!-- 评论的回复 -->
							<view class="as-reply" v-for="(reply,subs) in item.message" :key="subs">
								<view class="who">
									<image :src="reply.shavatar" mode="aspectFill"></image>
									<text>{{reply.shname}}</text>
									<view v-if="false">
										店家
									</view>
								</view>
								<view class="content">
									{{reply.coments}}
								</view>
							</view>
							<!-- 评论的回复end -->
		
						</view>
					</view>
				</block>
			</view>
		
		
			<view class="seeMore" @click="getMore1()" >
				{{ pjMText }} <!-- <text class="iconfont">&#xe600;</text> -->
			</view>
		</view>
		
		<!-- 底部 start -->
		<!-- 正常状态 -->
		<view class="dt-footer" v-if="data.product_sysproid != 8">
			<view class="ft-1" @click="navToTab('/pages/index/index')">
				<image src="/static/imgs/tabbar/home.png" mode=""></image>
				<view class="">
					首页
				</view>
				</navigator>
			</view>

			<view class="ft-1" @click="navTo('/pages/discountMall/shopCart')">
				<image src="/static/imgs/shoppingcart.png" mode="" class="shoppingcart"></image>
				<view>
					购物车
				</view>
			</view>

			<view class="ft-2">
				<view class="add-cart button" @click="buy('QSPopup-cart', 0)">加入购物车</view>
			</view>
			<view class="ft-2">
				<view class="ra-buy button" @click="buy('QSPopup-cart', 1)">立即购买</view>
			</view>


		</view>

		<!-- 拼团状态 -->
		<view class="dt-footer" v-else>
			<view class="ft-1" @click="navToTab('/pages/index/index')">
				<image src="/static/imgs/tabbar/home.png" mode="aspectFill"></image>
				<view class="">
					首页
				</view>
				</navigator>
			</view>

			<view class="ft-1" @click="navTo('/pages/discountMall/shopCart')">
				<image src="/static/imgs/shoppingcart.png" mode="aspectFill" class="shoppingcart"></image>
				<view>
					购物车
				</view>
			</view>

			<view class="ft-2">
				<view class="button yrp" @click="buy('QSPopup-cart', 0)">
					<text>￥16.8</text>
					<text>一人拼</text>
				</view>
			</view>
			<view class="ft-2">
				<view class="button kt" @click="buy('QSPopup-cart', 1)">
					<text>￥9.9</text>
					<text>我要开团</text>
				</view>
			</view>
		</view>

		<!-- 底部 end -->
		
		<!-- 添加留言的输入框 -->
	<!-- 	<view class="replied" v-if="lyFlag">
			<input type="text" v-model.trim="inputTextLy" @blur="lyBlur()" :focus="lyFlag" placeholder="请留言···" />
			<button type="primary" @click="onLy">发送</button>
		</view> -->
		
		<view class="replied" v-if="lyFlag">
			<input type="text"  v-model.trim="inputTextLy" @blur="lyBlur()" confirm-type="done" :focus="showFocus" placeholder="请留言···" />
			<button type="primary" @click="onLy">发送</button>
		</view>
		
		
		<!-- 弹窗加入购物车 -->
		<QSPopup ref="QSPopup-cart" type="fadeInUp1" @click.stop="aaa()">
			<view class="buy-menu">
				<view class="menu-line1">
					<image :src="data.product_imgs[0]" mode="aspectFill"></image>
					<view class="line1-right">
						<text class="text1">￥<text class="text2">{{data.product_nowprice * 1}}</text></text>
						<text class="text3">￥{{data.product_pronums * 1}}</text> <br />
						<text class="text4">仅剩{{data.product_pronums}}件</text>
					</view>
					<text class="iconfont" @click="hideQS('QSPopup-cart')">&#xe628;</text>
				</view>
				<view class="menu-line2">
					<text>规格</text>
					<text>默认</text>
				</view>
				<view class="menu-line2">
					<text>购买数量</text>
					<!-- <text>默认</text> -->
					<tui-numberbox :value="value" :max="data.product_pronums" @change="change" class="number-box"></tui-numberbox>
				</view>
				<button type="primary" @click="onfinish">完成</button>
			</view>
		</QSPopup>

	</view>
</template>

<script>
	import share from "@/components/share.js"; // 分享组件
	import QSPopup from '@/components/QS-popup/QS-popup.vue'; // 弹窗
	import tuiNumberbox from "@/components/numberbox/numberbox"; // 数字选择
	import tuiCountdown from "@/components/countdown/countdown"; // 倒计时
	import tuiRate from "@/components/rate/rate"; // 评分
	import {
		mapState,
		mapMutations
	} from "vuex";


	export default {
		components: {
			QSPopup,
			tuiNumberbox,
			tuiCountdown,
			tuiRate
		},
		filters: {
			countNum: function(value) {
				 let a = value.response || [];
				return a.length;
			}
		},
		data() {
			return {
				appraise_status: true,
				key: '',
				storeFlag: true,
				shopFlag: true,
				value: 1,
				selectType: 0, // 选择加入购物车，还是购买
				like: true,
				sortStatus: 0, // 分类状态
				proid: '',
				data: { // 所有数据
					product_imgs: [],
					product_video: []
				}, 
				leaveData: {}, // 留言的数据
				appraise: {}, // 评价的数据
				inputText: '', // 输入框
				lyMText: '查看更多···', // 留言底部查看更多
				pjMText: '查看更多···', // 评价底部查看更多
				cur_page2leave: 1,//
				pj_page2leave: 1,
				lyFlag: false, // 留言标识
				inputTextLy: '',// 留言内容
				userid: '', // 用户ID
			}
		},
		onLoad(option) {
			this.userid = uni.getStorageSync('lph-user-info').userid;
			this.getProductDetail(option.proid);
			this.getLeave();
			this.getAppraise();
		},
		methods: {
			...mapMutations(['addCart']),

			async getProductDetail(id) { // 获取商品数据
				let a = await this.$http.getProductDetails({product_id: id,userid: this.userid});
				if(a.code != 200){
					uni.navigateTo({
						url: '/pages/public/noDetailPage'
					})
				}
				this.data = a.data;
			},
			async getLeave() { // 详情页 留言数据
				this.cur_page2leave = 1
				let a = await this.$http.leave({
					product_id: 997,
					page: this.cur_page2leave
				});
				this.leaveData = a.data;
			},
			async getAppraise() { // 详情页 评价数据
				this.cur_page2leave = 1
				let a = await this.$http.appraise({
					product_id: 997,
					page: this.cur_page2leave
				});
				this.appraise = a.data;
			},
			onReply(val) { // 点击回复
				this.$set(val, 'replyFlag', true);
			},
			blur(val) { // 输入框失去焦点
				setTimeout(() => {
					this.$set(val, 'replyFlag', false);
				},200)
			},
			async getMore() { // 留言 加载更多
				let result = await this.$http.leave({
					product_id: 997,
					page: this.cur_page2leave + 1
				});
				if (result.data.count > 0) {
					this.cur_page2leave++;
					let data = result.data.response
					this.leaveData.response.push(...data)
					
				}
				else {
					this.lyMText = '没有更多了'
				}
			},
			async getMore1() { //  评价 加载更多
				let result = await this.$http.appraise({
					product_id: 997,
					page: this.pj_page2leave + 1
				});
				if (result.data.count > 0) {
					this.pj_page2leave++;
					let data = result.data.response;
					this.appraise.response.push(...data);
				}
				else {
					this.pjMText = '没有更多了'
				}
			},
			async onSend(val,who) { // 留言输入框回复
				
				if(who == 0) { // 
					let aa = {
						messid: val.messid,
						productid: val.productid,
						coments: this.inputText
					}
					console.log('留言');
					let a = await this.$http.setMessage(aa);
					if (a.code == 200) {
						uni.showToast({
							title: a.message,
							icon: 'none'
						})
						this.inputText = '', // 清空输入框
						uni.showToast({
							title: a.message,
							icon: 'none'
						})
						this.$set(val, 'replyFlag', false);
						setTimeout(() => {
							this.getLeave();
						},500)
						return
					}
					uni.showToast({
						title: a.message,
						icon: 'none'
					})
				}else {
					console.log('回复');
					let bb = {
						proid: val.proid,
						coments: this.inputText,
						commid: val.commid,
						orid: val.orid,
					}
					let a = await this.$http.setProComment(bb);
					if (a.code == 200) {
						uni.showToast({
							title: a.message,
							icon: 'none'
						})
						this.inputText = '', // 清空输入框
						uni.showToast({
							title: a.message,
							icon: 'none'
						})
						this.$set(val, 'replyFlag', false);
						setTimeout(() => {
							this.getAppraise();
						},500)
						return
					}
					uni.showToast({
						title: a.message,
						icon: 'none'
					})
				}
				
			},
			async onLy() { // 添加留言 发送
			
				let a = {
					coments: this.inputTextLy,
					productid: 997
				}
				let result = await this.$http.setProductMessage(a);
				if(result.code == 200){
					uni.showToast({
						title: '留言成功',
						icon: 'none'
					})
					this.inputTextLy
					this.getLeave();
					return
				}
				uni.showToast({
					title: result.message,
					icon: 'none'
				})
			},
			
			lyBlur() { // 留言输入框失去焦点
				setTimeout(() => {
					this.lyFlag = false;
				},200)
			},
			
			// 弹窗中的逻辑 start 
			buy(ref, num) { // 弹窗选规格
				let a = this.data.product_activity_surplus;
				if(a <= 0) {
					uni.showToast({
						title: '当前商品不在购买时间内，请选择其它商品购买吧~~',
						icon: 'none'
					})
					return
				}
				
				this.$refs[ref].show();
				this.selectType = num;
			},
			async onfinish() { // 弹窗中的完成

				if (this.selectType == 0) { // 添加到购物车
					let a = {
						product_id: this.data.product_id,
						shop_id: this.data.shop_id,
						quantity: this.value,
						delivery_type: 1
					}
					let b = await this.$http.setShoppingCart(a);
					if (b.code == 200) { // 购物车 模块
						uni.showToast({
							title: '已添加到购物车~~',
							icon: 'none'
						})
						this.$refs['QSPopup-cart'].hide();
						return
					}
					uni.showToast({
						title: b.message,
						icon: 'none'
					})
					return
				}
				// 进入确定订单界面
				this.$refs['QSPopup-cart'].hide();
				// let orderInfo = {
				// 	shopid: this.data.shopid,
				// 	proid: this.data.proid,
				// 	num: this.value,
				// 	img: this.data.proimgs[1],
				// 	goodsname: this.data.proname,
				// 	price: this.data.nowprice,
				// 	benefit: this.data.benefit,
				// 	shopname: this.data.shname,
				// 	limit: this.data.pronums,
				// 	express: '自提',
				// 	expressId: '1',
				// 	amount: '', // 总价
				// 	comment: ''
				// }
				setTimeout(() => {
					this.navTo(`/pages/discountMall/finishOrder?pro_id=${this.data.product_id}&quantity=${this.value}`);
				}, 300);


			},
			hideQS(ref) { //  隐藏弹窗
				this.$refs[ref].hide()
			},
			change: function(e) { // 数字选择
				this.value = e.value
			},
			
			// 弹窗中的逻辑 end
			navTo(url) { // 路由跳转
				uni.navigateTo({
					url
				});
			},
			navToTab(url) { // 路由到TabBar
				uni.switchTab({
					url
				});
			},
			navBack() { // 返回上一层
				uni.navigateBack();
			},
			async onStoreIcon(index) { // 店铺收藏
				console.log(index)
				if (this.data.attention == 1) { // 取消收藏
					let a = await this.$http.delStore({
						shopid: this.data.shop_id
					});
					if (a.code == 200) {
						this.data.attention = 0;
							uni.showToast({
								title: '取消收藏店铺成功',
								icon: 'none'
							});
						return
					}
					uni.showToast({
						title: a.message,
						icon: 'none'
					});
				};
				// 收藏操作
				let b = await this.$http.addStore({
					shopid: this.data.shop_id
				});
				if (b.code == 200) {
					this.data.attention = 1;
					uni.showToast({
						title: '收藏店铺成功',
						icon: 'none'
					});
					return
				}
				uni.showToast({
					title: b.message,
					icon: 'none'
				});
			},
			async onShopIcon() { // 商品收藏
				if (this.data.collect == 1) { // 取消收藏
					let a = await this.$http.deleteCollect({
						proid: this.data.product_id,
						shopid: this.data.shop_id
					});
					if (a.code == 200) {
						this.data.collect = 0;
						uni.showToast({
							title: '取消收藏宝贝成功',
							icon: 'none'
						});
						return
					}
					uni.showToast({
						title: a.message,
						icon: 'none'
					});
				};
				// 收藏操作
				let b = await this.$http.addCollect({
					proid: this.data.product_id,
					shopid: this.data.shop_id
				});
				if (b.code == 200) {
					this.data.collect = 1;
					uni.showToast({
						title: '成功收藏宝贝',
						icon: 'none'
					});
					return
				}
				uni.showToast({
					title: b.message,
					icon: 'none'
				});
			},
			aaa() {
				return true;
			},
			shareInfo() { // 分享功能的实现
				let shareInfo = {
					href: "https://uniapp.dcloud.io",
					title: "分享测试",
					desc: "分享测试",
					imgUrl: "/static/logo.png"
				};
				let shareList = [{
						icon: "/static/imgs/sharemenu/wx.png",
						text: "微信好友",
					},
					{
						icon: "/static/imgs/sharemenu/pyq.png",
						text: "朋友圈"
					},
					{
						icon: "/static/imgs/sharemenu/weibo.png",
						text: "微博"
					},
					{
						icon: "/static/imgs/sharemenu/qq.png",
						text: "QQ"
					},
					{
						icon: "/static/imgs/sharemenu/copy.png",
						text: "复制"
					},
					{
						icon: "/static/imgs/sharemenu/more.png",
						text: "更多"
					},
				];
				this.shareObj = share(shareInfo, shareList, function(index) {
					console.log("点击按钮的序号: " + index);
					let shareObj = {
						href: shareInfo.href || "",
						title: shareInfo.title || "",
						summary: shareInfo.desc || "",
						success: (res) => {
							console.log("success:" + JSON.stringify(res));
						},
						fail: (err) => {
							console.log("fail:" + JSON.stringify(err));
						}
					};
					switch (index) {
						case 0:
							shareObj.provider = "weixin";
							shareObj.scene = "WXSceneSession";
							shareObj.type = 0;
							shareObj.imageUrl = shareInfo.imgUrl || "";
							uni.share(shareObj);
							break;
						case 1:
							shareObj.provider = "weixin";
							shareObj.scene = "WXSenceTimeline";
							shareObj.type = 0;
							shareObj.imageUrl = shareInfo.imgUrl || "";
							uni.share(shareObj);
							break;
						case 2:
							shareObj.provider = "sinaweibo";
							shareObj.type = 0;
							shareObj.imageUrl = shareInfo.imgUrl || "";
							uni.share(shareObj);
							break;
						case 3:
							shareObj.provider = "qq";
							shareObj.type = 1;
							shareObj.imageUrl = shareInfo.imgUrl || "";
							uni.share(shareObj);
							break;
						case 4:
							uni.setClipboardData({
								data: shareInfo.href,
								complete() {
									uni.showToast({
										title: "已复制到剪贴板"
									})
								}
							})
							break;
						case 5:
							plus.share.sendWithSystem({
								type: "web",
								title: shareInfo.title || "",
								thumbs: [shareInfo.imgUrl || ""],
								href: shareInfo.href || "",
								content: shareInfo.desc || "",
							})
							break;
					};
				});
				this.$nextTick(() => {
					this.shareObj.alphaBg.show();
					this.shareObj.shareMenu.show();
				})
			}

		},
		onShow() {

		},
		// #ifdef APP-PLUS
		onBackPress() {
			//监听back键，关闭弹出菜单
			if (this.shareObj.shareMenu.isVisible()) {
				this.shareObj.shareMenu.hide();
				this.shareObj.alphaBg.hide();
				return true
			}
		},
		// #endif

	}
</script>

<style lang="scss" scoped>
	@import 'static/css/goodsDetail.scss';
	@import 'static/css/myStore.scss';
</style>
